package com.findFish.fish.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.fish.domain.FishGrowth;
import com.findFish.fish.service.IFishGrowthService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 鱼类生长记录Controller
 * 
 * @author ruoyi
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/fish/growth")
public class FishGrowthController extends BaseController
{
    @Autowired
    private IFishGrowthService fishGrowthService;

    /**
     * 查询鱼类生长记录列表
     */
    @PreAuthorize("@ss.hasPermi('fish:growth:list')")
    @GetMapping("/list")
    public TableDataInfo list(FishGrowth fishGrowth)
    {
        startPage();
        List<FishGrowth> list = fishGrowthService.selectFishGrowthList(fishGrowth);
        return getDataTable(list);
    }

    /**
     * 导出鱼类生长记录列表
     */
    @PreAuthorize("@ss.hasPermi('fish:growth:export')")
    @Log(title = "鱼类生长记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FishGrowth fishGrowth)
    {
        List<FishGrowth> list = fishGrowthService.selectFishGrowthList(fishGrowth);
        ExcelUtil<FishGrowth> util = new ExcelUtil<FishGrowth>(FishGrowth.class);
        util.exportExcel(response, list, "鱼类生长记录数据");
    }

    /**
     * 获取鱼类生长记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('fish:growth:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fishGrowthService.selectFishGrowthById(id));
    }

    /**
     * 新增鱼类生长记录
     */
    @PreAuthorize("@ss.hasPermi('fish:growth:add')")
    @Log(title = "鱼类生长记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FishGrowth fishGrowth)
    {
        return toAjax(fishGrowthService.insertFishGrowth(fishGrowth));
    }

    /**
     * 修改鱼类生长记录
     */
    @PreAuthorize("@ss.hasPermi('fish:growth:edit')")
    @Log(title = "鱼类生长记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FishGrowth fishGrowth)
    {
        return toAjax(fishGrowthService.updateFishGrowth(fishGrowth));
    }

    /**
     * 删除鱼类生长记录
     */
    @PreAuthorize("@ss.hasPermi('fish:growth:remove')")
    @Log(title = "鱼类生长记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fishGrowthService.deleteFishGrowthByIds(ids));
    }
}
